import Request from "@/util/request.js";

const apiRequest = new Request();

// 获取数据库的所有表
export const getTablesApi = async (data) => {
    return await apiRequest.post("/api/database.table/index", data);
}

// 同步表
export const syncTableApi = async (data) => {
    return await apiRequest.post("/api/database.table/syncTable", data);
}

// 设置表名称
export const setTableTitleApi = async (data) => {
    return await apiRequest.post("/api/database.table/setTableTitle", data);
}

// 获取表的字段
export const getFieldsApi = async (data) => {
    return await apiRequest.post("/api/database.table/fields", data);
}

// 读取表单配置
export const readTableFormApi = async (data) => {
    return await apiRequest.post("/api/database.table/readTableForm", data);
}

// 保存表单配置
export const saveTableFormApi = async (data) => {
    return await apiRequest.post("/api/database.table/saveTableForm", data);
}

// 读取检索配置
export const readTableSearchApi = async (data) => {
    return await apiRequest.post("/api/database.table/readTableSearch", data);
}

// 保存检索配置
export const saveTableSearchApi = async (data) => {
    return await apiRequest.post("/api/database.table/saveTableSearch", data);
}

// 获取数据源列表
export const getSourceListApi = async (data) => {
    return await apiRequest.post("/api/database.source/index", data);
}

// 获取数据源信息
export const getSourceApi = async (data) => {
    return await apiRequest.post("/api/database.source/getSource", data);
}

// 保存数据源
export const saveSourceApi = async (data) => {
    return await apiRequest.post("/api/database.source/setSource", data);
}

export const getSourceItemsApi = async (data) => {
    return await apiRequest.post("/api/database.source/items", data);
}


// 获取列表页配置
export const getTableListApi = async (data) => {
    return await apiRequest.post("/api/database.table/getTableList", data);
}

// 保存列表页配置
export const saveTableListApi = async (data) => {
    return await apiRequest.post("/api/database.table/setTableList", data);
}

// 通用列表接口
export const getListApi = async (data) => {
    return await apiRequest.post("/api/database.general/index", data);
}

// 获取婚车列表
export const getCarListApi = async () => {
    return await apiRequest.post("/api/database.special/cars", {})
}

// 通用读取接口
export const readDataApi = async (data) => {
    return await apiRequest.post("/api/database.general/read", data);
}

// 通用创建接口
export const createDataApi = async (data) => {
    return await apiRequest.post("/api/database.general/create", data);
}

// 通用更新接口
export const updateDataApi = async (data) => {
    return await apiRequest.post("/api/database.general/update", data);
}

// 通用删除接口
export const deleteDataApi = async (data) => {
    return await apiRequest.post("/api/database.general/delete", data);
}

// 通用导出接口
export const exportDataApi = async (data) => {
    return await apiRequest.post("/api/database.general/export", data);
}

// 获取模型列表
export const getModelListApi = async (data) => {
    return await apiRequest.post("/api/database.source/models", data);
}

// 获取模型目录
export const getModelCatalogApi = async (data) => {
    return await apiRequest.post("/api/database.source/catalog", data);
}

// 获取模型详情
export const getModelApi = async (data) => {
    return await apiRequest.post("/api/database.table/getTableModel", data);
}

// 创建模型
export const createModelApi = async (data) => {
    return await apiRequest.post("/api/database.table/setTableModel", data);
}

// 获取模型目录
export const getCatalogApi = async (data) => {
    return await apiRequest.post("/api/database.source/catalog", data);
}

// 生成表型
export const generateTableModelApi = async (data) => {
    return await apiRequest.post("/api/database.source/buildModel", data);
}





